#include <jni.h>
#include <string>
#include <fstream>

#include <cinttypes>
#include <iostream>
#include <ios>
#include <stdio.h>
#include <vector>

#include "decrypt/EncryptManager.h"

static EncryptManager sEncryptManager;

extern "C"
JNIEXPORT
jint JNI_OnLoad(JavaVM *vm, void *res) {

    JNIEnv *env = NULL;
    if (vm->GetEnv((void **) &env, JNI_VERSION_1_4) != JNI_OK) {
        return -1;
    }

    return JNI_VERSION_1_4;
}



extern "C"
JNIEXPORT jboolean JNICALL
Java_com_shinektv_utils_FileIsH265Encrypt_native_1ish265(JNIEnv *env, jclass clazz, jstring path) {
    // TODO: implement native_ish265()

    bool isH265 = false;
    const char *url = env->GetStringUTFChars(path, 0);
    isH265 = sEncryptManager.isH265(url);
    env->ReleaseStringUTFChars(path, url);
    return isH265;
}

extern "C"
JNIEXPORT jint JNICALL
Java_com_shinektv_utils_FileIsH265Encrypt_native_1getFileType(JNIEnv *env, jclass clazz,
                                                              jstring path) {
    // TODO: implement native_getFileType()
    int type = 0;
    const char *url = env->GetStringUTFChars(path, 0);
    type = sEncryptManager.getType(url);
    env->ReleaseStringUTFChars(path, url);
    return type;
}